package com.nongfuspring.nongfu.controller;

import com.nongfuspring.nongfu.pojo.Menu;
import com.nongfuspring.nongfu.pojo.ResponseBean;
import com.nongfuspring.nongfu.pojo.Result;
import com.nongfuspring.nongfu.pojo.RouterVo;
import com.nongfuspring.nongfu.service.SysTemMenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class HelloController {


    private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(HelloController.class);
    @Autowired
    SysTemMenuService sysTemMenuService;

    @GetMapping("/hello1")
    public void Hello1 (){
        System.out.println("anyone can touch");
    }

    @GetMapping("/admin/hello2")
    public void Hello2 (){
        System.out.println("admin can touch");
    }

    @GetMapping("/user/hello2")
    public void Hello3 (){
        System.out.println("user can touch");
    }

    @GetMapping("/admin/getmenus")
    public Result  getmenus(Integer userid){
        List<Menu> menuList = sysTemMenuService.getMenuByRole(userid);
        List<RouterVo> routerVoList = sysTemMenuService.buildMenus(menuList);
        return Result.success(200,"请求成功",routerVoList);
    }

}
